home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
UTILITY
/
DO1002.ARJ
/
REPEAT.SCR
< prev
next >
Wrap
Text File
|
1991-12-03
|
2KB
|
66 lines
.pg wi full clr cy
COMMAND NAME»gray«: »%t« RepeatLoop »ye«
/REPEAT
/UNTIL {value1} [EQ/LT/GT/NE/GE/LE/LK] {value}[ [{else label}][ ASIS]]»gray«
/DRAW H 5 1 78
.wi 1 6 79 25 #
»wh«The »%t«/REPEAT»wh« and »%t«/UNTIL»wh« commands must be used in a pair. The
section of the script between these commands is repeated
until the condition on the »%t«/UNTIL»#« statement is true. Then
the script continues with the next command after the »%t«/UNTIL»#«.
The »%t«/UNTIL»#« command is evaluated the same as the Compare
(»%t«/IF»#«) command.
»%t«/REPEAT»#« loops can be nested up to »ye«10»#« deep.
.pg clr
Let's look at a couple of nested loops just to see how things
work. We'll use Counter's 1 and 2 to control the »%t«/REPEAT»#«
execution. Here are the loops we'll use:
»wh«
/MATH Counter1 0
»%t«/REPEAT»cy« -----------------+
»wh«/MATH Counter2 2»cy« |
»%t«/REPEAT»cy« ---------------+ |
»wh«/DEC Counter2»cy« | |
»%t«/UNTIL»wh« %%Counter2 EQ 0»cy« <+ |
»wh«/INC Counter1 0.5»cy« |
»%t«/UNTIL»wh« %%Counter1 EQ 2»cy« <--+
.pg 25 wi 40 11 79 25 gr
Now let's watch the execution
at the bottom of the screen»gray«:»#«
/SET C1 ye
|/MATH Counter1 0
|/REPEAT This loop repeats until counter 1 eq 2
|/MATH Counter2 2
/SET C2 ye
.go 1 4
»cy«Counter 1»gray«: »%c1«%Counter1(##.#)»#«
.go 1 5
»cy«Counter 2»gray«: »%c2«%Counter2(##.#)»#«
|/REPEAT This loop repeats until counter 2 eq 0
|/DEC Counter2
/if %Counter2 EQ 0 Reset2
/SET C2 +re
/GOTO Cont2
:Reset2
/SET C2 ye
:Cont2
.go 1 5
»cy«Counter 2»gray«: »%c2«%Counter2(##.#)»#«
|/UNTIL %Counter2 EQ 0
|/INC Counter1 0.5
/if %Counter1 EQ 2 Cont1
/SET C1 +re
:cont1
.go 1 4
»cy«Counter 1»gray«: »%c1«%Counter1(##.#)»#«
|/UNTIL %Counter1 EQ 2
.go 1 7
Since both »%t«/UNTIL»#« statements have
been satisfied, the »%t«/REPEAT»#« loops
terminate.
/ENDEXEC CLEAR